<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<%try{ %>
<%@ include file="/common/meta.jsp"%>
<title>发现|365博客</title>
<link href="${ctx }/skins/index.css" rel="stylesheet" type="text/css" />
<link href="${ctx }/skins/tag.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function(){
	var search = "${param.tag}";
	search = $.trim(search);
	if(search==null||search.length==0)
		$("#tag-search-input").attr("value", "搜索你感兴趣的标签");
	else
		$("#tag-search-input").val(search);
	/*进入焦点时触发*/
	$("#tag-search-input").focus(function() {
		var oldValue = $(this).val();
		if (oldValue == "搜索你感兴趣的标签") {
			$(this).val("");
		}
	});
	/*失去焦点时触发*/
	$("#tag-search-input").blur(function() {
		var oldValue = $(this).val();
		if (oldValue == "") {
			$(this).val("搜索你感兴趣的标签");
		}
	});
});
function beforeSearch() {
	var searchValue = $("#tag-search-input").val();
	if (searchValue == null || searchValue.length == 0
			|| searchValue == "搜索你感兴趣的标签") {
		$("#tag-search-input").focus();
		return false;
	}
}
</script>
</head>
<body id="page-home">
	<%@ include file="/common/header.jsp"%>
	<div class='page-content'>
		<div id='column-left'><%@ include file="/common/left.jsp"%></div>
		<div id="column-main"
			style="width:900px; padding: 10px 24px; background: url(../img/sidemenu-item.$5106.png) repeat;">
			<div id="tag-search-outer">
				<div id="tag-search-holder">
					<form id="tag-search-form" method="post"
						action="${ctx }/blog/blog.action">
						<div id="tag-search-box">
							<input type="text" id="tag-search-input" class="input-tip"
								name="tag" value="${param.tag}" />
						</div>
						<button type="submit" id="tag-go-search" name="method:articleTag"
							onclick="return beforeSearch();">搜索你感兴趣的标签</button>
					</form>
				</div>
			</div>
			<div class="hot-tags-holder">
				<table class="hot-tags-table" cellpadding="0" cellspace="0">
					<thead>
						<tr class="tag-hd-row">
							<th class="tag-hd">热门标签</th>
							<th class="relative-hd">相关标签</th>
							<th class="active-hd">关联文章数</th>
							<th class="lastblog-hd">最近推荐</th>
							<th class="editor-hd">杰出博客</th>
						</tr>
					</thead>
					<nativeSql:sqlQueryForList
						sql="select *,count(*) as num from t_tag_mark 
						where f_relate_entity_id in 
						(select f_id from t_article where f_blog_id in (select f_id from t_blog where f_if_personal = '1'))
						group by f_tag_name order by num desc limit 30"
						id="popTags" />
					<tbody>
						<c:forEach items="${popTags }" var="popTag" varStatus="status">
							<c:if test="${status.count%2==1}">
								<tr class="tag-row even">
							</c:if>
							<c:if test="${status.count%2==0}">
								<tr class="tag-row odd">
							</c:if>
							<td class="tag">
								<div class="tag-ct">
									<a
										href="${ctx}/blog/blog.action?method:articleTag&tag=${popTag.f_tag_name}"
										target="_blank">${popTag.f_tag_name}</a> <span class="new-tip"></span>
								</div></td>
							<td class="relative">
							<nativeSql:sqlQueryForList sql="select max(f_creation_date),f_tags from t_article where f_tags like 
							'%${popTag.f_tag_name}%' and f_blog_id in (select f_id from t_blog where f_if_personal='1') " id="article"/>
							<c:set var="string1"
									value="${fn:split(article[0].f_tags,',') }" /> <c:set var="string2"
									value="${fn:join(string1,'，') }" /> <c:set var="string3"
									value="${fn:split(string2,'，') }" /> <c:set var="string4"
									value="${fn:join(string3,' ') }" /> <c:set
									value="${fn:split(string4,' ') }" var="tags" /> 
									<c:set var="len" value="${fn:length(tags)}"/>
									<c:forEach
									var="tag" items="${tags}" varStatus="status1">
									<c:if test="${tag!=popTag.f_tag_name}">
									<a href="${ctx}/blog/blog.action?method:articleTag&tag=${tag}"
										target="_blank">${tag}</a>
									<c:if test="${status1.index+2<len}">
										<span class="comma">,</span>
									</c:if>
									</c:if>
								</c:forEach></td>
							<td class="active">
								<div class="active-bar-holder clearfix">
									<hql:queryForUnique
										hql="select count(*) from Article where tags like '%${popTag.f_tag_name}%'"
										id="all" />
									${all}
								</div></td>
							<td class="lastblog"><nativeSql:sqlQueryForList
									sql="select * from t_blog
				where f_if_personal=1 and f_id in 
				 ( select f_blog_id from t_article where f_tags like '%${popTag.f_tag_name}%') 
				order by f_creation_date desc limit 1"
									id="blog1" /><a
								href="${ctx }/blog/blogIndex.jsp?blogId=${blog1[0].f_id}"
								target="_blank" class="lastblog-info"> ${blog1[0].f_blog_name}</a>
							</td>
							<td class="editor"><nativeSql:sqlQueryForList
									sql="select p.f_blog_name,p.f_id from t_blog p
				where p.f_if_personal=1 and p.f_id in 
				( select f_blog_id from t_article where f_tags like '%${popTag.f_tag_name}%') 
				order by (select sum(f_click) from t_article where f_blog_id = p.f_id) desc"
									id="blog2" /> <a
								href="${ctx }/blog/blogIndex.jsp?blogId=${blog2[0].f_id}"
								target="_blank" class="editor-info">${blog2[0].f_blog_name}</a>
							</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</body>
<%}catch(Exception e){e.printStackTrace();}
	%>
</html>